package com.reder.practice.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * Swagger2 配置
 *
 * @author Fish
 * <p>Email: fishinlove@163.com</p>
 * <p>created by 2019/09/26 14:50:15</p>
 */
@Configuration
@EnableSwagger2 // 开启 Swagger2
public class SwaggerConfig {

    // 配置 Swagger2 的 Docket 实例
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 设置要扫描的包
                .apis(RequestHandlerSelectors.basePackage("com.reder.practice.controller"))
                .build();
    }

    // 返回 API 信息
    private ApiInfo apiInfo() {
        return new ApiInfo(
                // 标题，描述，版本号，团队服务网站
                "简易 VLOG 应用 API 文档", "Api 文档", "1.0", "https://gitee.com/theWayToGo",

                // 联系方式
                new Contact("TheWayToGo", "https://gitee.com/theWayToGo", "无"),

                // 开源协议，协议网站，渲染插件
                "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<>());
    }
}
